<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <a href="#state1">push state1</a>
  <a href="#state2">push state2</a>
  <a href="#state3">push state3</a>
  <br />
  <button onclick="his()">history</button>
  <br />
  <button onclick="back()">back</button>
  <button onclick="forward()">forward</button>
  <button onclick="go()">go</button>
  <button onclick="pushState()">pushState</button>
  <button onclick="repalceState()">repalceState</button>
  <script>
    // 路由基石
    function his() {
      console.log(history)
    }
    function back() {
      history.back()
    }
    function forward() {
      history.forward()
    }
    function go() {
      history.go(-1)
    }
    function pushState() {
        //携带参数   短标题  地址
      history.pushState({name:"xixi"},'haha','index.html')
    }
    function repalceState() {
      history.replaceState({age:18},'','demo.html')
    }
  </script>
</body>

</html>